package com.yigo.cuc.domain.customer.valueobject;

import cn.hutool.core.util.StrUtil;
import com.yigo.framework.annotation.ValueObject;
import com.yigo.framework.http.BException;
import com.yigo.framework.http.RCodeEnum;
import lombok.Data;

@Data
@ValueObject
public class CustomerUserName {
    private String userName;

    public void setUserName(String userName) {
        if (StrUtil.isBlank(userName)) {
            throw new BException(RCodeEnum.PARAMS_VALID_ERROR, "用户名不能为空");
        }
        if (userName.length() < 6) {
            throw new BException(RCodeEnum.PARAMS_VALID_ERROR, "用户名长度需要大于等于6");
        }
        this.userName = userName;
    }
}
